package com.example.util;


import com.example.bean.ConsumerComponent;

/**
 * @author kangshuai
 */
public class Consume implements Runnable {
    protected ConsumerComponent service;
    private String method;

    public Consume(ConsumerComponent s, String m) {
        service = s;
        method = m;
    }

    protected void call() throws Exception {
        if (method == "A") {
            service.aMethod();
        } else if (method == "B") {
            service.bMethod();
        } else if (method == "C") {
            service.cMethod();
        }
    }

    @Override
    public void run() {
        while (true) {
            try {
                call();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
